<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<script type="text/javascript">
		function getByClass(oParent,sClass){
			var aResult=[];
			var aEle=oParent.getElementsByTagName('*');
			for(var i=0;i<aEle.length;i++){
				if(aEle[i].className==sClass){
                   aResult.push(aEle[i]);
				}
			}
			return aResult;
		}
		window.onload=function (){
			var oUi=document.getElementById('ul1');
			var aBox=getByClass(oUi,'box');
			for(var i=0;i<aBox.length;i++){
				aBox[i].style.background='red';
			}
		}
	</script>
</head>
<body>
	<ul id="ul1">
		<li class="box"></li>
		<li></li>
		<li></li>
		<li class="box"></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li class="box"></li>
		<li class="box"></li>
	</ul>
</body>
</html>